package com.mall.controller;

import com.mall.entity.Orders;
import com.mall.entity.OrderVO;
import com.mall.service.OrderService;
import com.mall.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("/add")
    public ResultVO addOrder(String[] cids,@RequestBody Orders order){

        Map<String, String> orderInfo = orderService.addOrder(cids, order);
        if (orderInfo!=null){
            return orderService.getWXPay(orderInfo);
        }else{
            return ResultVO.fail("订单保存失败！");
        }
    }

}
